#ifndef TD_TOWER_INFO_PANEL_H_
#define TD_TOWER_INFO_PANEL_H_


/************************************************************************/
/* STL                                                                  */
/************************************************************************/
#include <string>
#include <sstream>

/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/

/************************************************************************/
/* GUI                                                                  */
/************************************************************************/
#include "GUI/Panels/BasePanel.h"
#include "GUI/TextMessages/TextMessage.h"
#include "GUI/Buttons/BaseButton.h"

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/ResourceManager.h"

using namespace std;

namespace TD_GUI {



	class TowerInfoPanel : public BasePanel {

		/************************************************************************/
		/* Default definitions                                                  */
		/************************************************************************/
		static const string m_towerInfoBackground;
		static const Coord2D m_infoPanelPosition;
		static const Coord2D m_infoPanelSize;

		/** Current tower which the info will be shown.*/
		TD_Game::BaseTower * m_pTower;
		const TD_Game::BaseTower *m_pConstTower;

		/** Showing the instanced tower info.*/
		bool m_showButtons;

		/** Text boxes: */
		TextMessage *m_pTowerName;
		TextMessage *m_pTowerPrice;
		TextMessage *m_pTowerDamage;
		TextMessage *m_pTowerRange;
		TextMessage *m_pTowerCooldown;
		TextMessage *m_pTowerSellPrice;
		TextMessage *m_pTowerUpgradePrice;
		TextMessage *m_pTowerUpgradeDamage;
		TextMessage *m_pTowerUpgradeRange;
		TextMessage *m_pTowerUpgradeCooldown;
		Tile * m_towerDescription;

		/** Buttons: */
		BaseButton *m_pUpgradeButton;
		BaseButton *m_pSellButton;



		/************************************************************************/
		/* Private functions                                                    */
		/************************************************************************/
		static int upgradeButtonOnClick(int mouseButton, const Coord2D & mousePos);

		void initTextboxes();
		
	public:

		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit TowerInfoPanel();

		//Copy constructor
		explicit TowerInfoPanel(const TowerInfoPanel &rhs);

		//Assignment constructor
		TowerInfoPanel& operator=(const TowerInfoPanel &rhs);

		//Destructor
		~TowerInfoPanel();


		/************************************************************************/
		/* Functionalities                                                      */
		/************************************************************************/
		inline void setTargetTower(TD_Game::BaseTower *infoTower) {

			m_showButtons = true;
			m_pTower = infoTower;
			updateTowerInfo();
		}

		/************************************************************************/
		/* Functionalities                                                      */
		/************************************************************************/
		inline void setTargetTower(const TD_Game::BaseTower *infoTower) {
			m_showButtons = false;
			m_pConstTower = infoTower;
			updateTowerInfo();
		}

		inline void updateTowerInfo() {
			const TD_Game::BaseTower *pTemp;
			if(m_showButtons) {
				pTemp = (const TD_Game::BaseTower *)m_pTower;
			} else {
				pTemp = m_pConstTower;
			}

			m_pTowerName->setText(pTemp->getName());
			m_towerDescription = pTemp->getDescriptionTile();


			m_pTowerPrice->setText(intToStr(pTemp->getPrice()));
			
			m_pTowerUpgradePrice->setText(" + " + intToStr(pTemp->getPriceToUpdate() - pTemp->getPrice()));
			
			m_pTowerDamage->setText(intToStr(pTemp->getDamage()));
			m_pTowerUpgradeDamage->setText(" + " + intToStr(pTemp->getNextLevelDamage() - pTemp->getDamage()));
			
			m_pTowerRange->setText(intToStr(pTemp->getBaseTowerRadius()));
			m_pTowerUpgradeRange->setText(" + " + intToStr(pTemp->getNextLevelRange() - pTemp->getBaseTowerRadius()));

			m_pTowerCooldown->setText(intToStr(pTemp->getShootingInterval()));
			m_pTowerUpgradeCooldown->setText(" + " + intToStr(pTemp->getNextLevelCooldown() - pTemp->getShootingInterval()));


			if(m_showButtons) {
				m_pTowerSellPrice->setText("$" + intToStr(pTemp->getSellPrice()));
			}



		}

		inline TD_Game::BaseTower * getTargetTower() const {
			return(m_pTower);
		}

		

		/************************************************************************/
		/* Rendering                                                            */
		/************************************************************************/
		void render(SDL_Surface *const g_destSurface, unsigned int deltaTime);

		interaction_t processEvent(const SDL_Event &event);
	};
}


#endif